package com.netrust.cmsx.entity.module.cms;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.netrust.cmsx.entity.module.sys.Attach;



/**
 * 文章附件表
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_attach_article")
public class AttachArticle {
    private Integer id;
    @JsonIgnore
    private Integer aid;//文章id
    @JsonIgnore
    private Integer aaid;//附件id
    @JsonIgnore
    private Article article;
    @JsonIgnore
    private Attach attach;//附件表关联id
    
    
	public AttachArticle() {
		super();
	}

	public AttachArticle(Article article,Attach attach) {
		super();
		this.article = article;
		this.attach = attach;
	}
	
	public AttachArticle(Integer id, Integer aid, Integer aaid, Article article, Attach attach) {
		super();
		this.id = id;
		this.aid = aid;
		this.aaid = aaid;
		this.article = article;
		this.attach = attach;
	}

	@Id
  	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ap_id", unique = true, nullable = false)
    public Integer getId() {
		return id;
	}
    
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name="a_uid",insertable=false,updatable=false)
	public Integer getAid() {
		return aid;
	}

	public void setAid(Integer aid) {
		this.aid = aid;
	}
	
	@Column(name="a_id",insertable=false,updatable=false)
	public Integer getAaid() {
		return aaid;
	}

	public void setAaid(Integer aaid) {
		this.aaid = aaid;
	}

	@ManyToOne(fetch=FetchType.EAGER,cascade = CascadeType.ALL)
	@JoinColumn(name="a_uid")
	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}
	
	@ManyToOne(fetch=FetchType.EAGER,cascade = CascadeType.ALL)
	@JoinColumn(name="a_id")
	public Attach getAttach() {
		return attach;
	}
	public void setAttach(Attach attach) {
		this.attach = attach;
	}

	@Override
	public String toString() {
		return "AttachArticle [id=" + id + ", aid=" + aid + ", aaid=" + aaid + ", article=" + article + ", attach="
				+ attach + "]";
	}


    
}